//Pietras93OS
//Schedule
//pietras93@gmail.com
//

#ifndef SCHED_H
#define SCHED_H

#include <setjmp.h>

typedef struct
{
        int window;
        jmp_buf state;
        enum
        {
                TS_FREE = 0, TS_RUNNABLE = 1, TS_BLOCKED = 2, TS_ZOMBIE = 3
        } status;
        unsigned char *owner;
        unsigned char *desc;
        enum
        {
                PR_LOW = 1, PR_NORMAL = 2, PR_HIGH = 3, PR_REALTIME = 4
        } priority;
        int pid;
} task_t;

void schedule(void);
void init_tasks(void);
void kill_task(int pid);
int gettask(void);
int add_task(unsigned taskaddress, char* owner, int priority, char *desc);
void demotask(void); // Prototype of demotask in tasks.c

#define NUM_TASKS        5          // Number of demo tasks to create

#define MAX_TASK         1024
#define USER_STACK_SIZE  512
#define JMPBUF_IP        eip        /*  j_ip    __eip    __pc  */
#define JMPBUF_SP        esp        /*  j_sp    __esp    __sp  */
#define JMPBUF_FLAGS     eflags     /*  j_flag  __eflags ?     */

task_t *_curr_task;
task_t _tasks[MAX_TASK];

#endif
